package Map_2;

import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

public class TestMarket {
    public static void main(String[] args) {
        File file = new File("Market.txt");
        Scanner input = new Scanner(System.in);
        Market market = Market.getFromFile();
        if (market==null){
            market=new Market();
            System.out.println("输出超市姓名");
            market.setName(input.next());
            System.out.println("输入超市地址");
            market.setAdress(input.next());
        }
        market.setAdress("天水路128号");
        market.setName("子梅爱家超市");
        while (true) {
            System.out.println("欢迎光临子梅爱家超市会员系统");
            System.out.println("1：添加会员");
            System.out.println("2：显示会员信息");
            System.out.println("3：显示商场信息");
            System.out.println("4：添加会员积分");
            System.out.println("5：查询会员积分");
            System.out.println("6：会员积分兑换商品");
            System.out.println("7：修改会员卡密码");
            System.out.println("0：退出系统");
            int chioce = input.nextInt();
            switch (chioce) {
                case 1:
                    System.out.println("请输入会员姓名");
                    String name = input.next();
                    System.out.println("请输入会员卡号");
                    String cardNo = input.next();
                    System.out.println("请输入会员手机号");
                    String number = input.next();
                    System.out.println("请输入会员积分");
                    int score = input.nextInt();
                    System.out.println("请输入会员密码");
                    String password = input.next();
                    Calendar calendar = Calendar.getInstance();
                    String cardOpeningTime = new SimpleDateFormat("yyyy年MM月dd日 ").format(calendar.getTime());
                    market.add(name, cardNo, number, score, password, cardOpeningTime);
                    break;
                case 2:
                    market.showMember();
                    break;
                case 3:
                    market.show();
                    break;
                case 4:
                    System.out.println("请输入需要添加积分的会员卡号");
                    String cardNo2 = input.next();
                    System.out.println("请输入您要增加的积分");
                    int score1 = input.nextInt();
                    market.increaseScore(cardNo2, score1);
                    break;
                case 5:
                    System.out.println("请输入您要查询的会员卡号");
                    String cardNo1 = input.next();
                    market.check(cardNo1);
                    break;

                case 6:
                    System.out.println("1:100积分兑换餐巾纸一包，2:400积分兑换剃须刀一把，3:1000积分兑换铁锅一个");
                    System.out.println("请输入会员卡号");
                    String cardNO3 = input.next();
                    System.out.println("请输入您要兑换的商品编号");
                    int no = input.nextInt();
                    market.exchange(cardNO3, no);
                    break;
                case 7:
                    System.out.println("请输入需要修改密码的卡号");
                    String cardNo4 = input.next();
                    System.out.println("请输入旧密码");
                    String oldpassword = input.next();
                    System.out.println("请输入新密码");
                    String newpassword = input.next();
                    market.changePassword(cardNo4, oldpassword, newpassword);
                    break;
                default:
                    Market.setObjfile(market);
                    break;
            }
            if (chioce == 0) {
                System.out.println("退出系统");
                break;
            }
        }

    }
}
